-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
opentelemetry: enforce event_location for span tags #2124
Conversation
The `with_event_location` method will now properly omit `code.*` tags from spans.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks correct to me.
I do have one thought about the API, though: the name of the method is with_event_location
, but now it controls whether locations are included for both events and spans. It seems like it would make more sense if we did one of the following:
- rename the method to just
with_location
- have separate
with_event_location
andwith_span_location
methods
Which choice is the correct one depends a bit on whether we think users would want to control whether locations are included for events and spans separately --- which, IMO, doesn't really seem necessary. I think we should probably just rename the method to with_location
(leaving a deprecated version of with_event_location
that says "renamed to with_location
", to avoid a breaking change), unless we think people are going to want to configure these separately.
cc @jtescher what do you think?
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and renamed the method to with_location
. This looks good to me now, thanks for the fix!
The `with_event_location(false)` method will now properly omit `code.*` tags from spans. ## Motivation Recently, I attempted to remove the `code.*` tags from opentelemetry tracing spans utilizing the [`with_event_location`] of OpenTelemetrySubscriber. This did not work as expected because the [`on_new_span`] doesn't account for the `event_location` boolean similar to how [`on_event`] does. ## Solution The change presented will expand the use of the `location` field to check before adding the `code.*` KeyValue attributes in `on_new_span`. In addition, `with_event_location` was renamed to `with_location`, as it now controls both span *and* event locations, and the `with_event_location` method has been deprecated. ## Testing Additional unit tests are included in [tracing-opentelemetry/src/subscriber.rs] to cover both boolean cases of `with_location`. [`with_event_location`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L343 [`on_new_span`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L448-L460 [`on_event`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L582 [tracing-opentelemetry/src/subscriber.rs]: https://github.com/tokio-rs/tracing/pull/2124/files#diff-69011e8b23dffcbe19b9b72e5ac54330a7871f424a90700ed7f5c5686daf431bR911-R975)
The `with_event_location(false)` method will now properly omit `code.*` tags from spans. ## Motivation Recently, I attempted to remove the `code.*` tags from opentelemetry tracing spans utilizing the [`with_event_location`] of OpenTelemetrySubscriber. This did not work as expected because the [`on_new_span`] doesn't account for the `event_location` boolean similar to how [`on_event`] does. ## Solution The change presented will expand the use of the `location` field to check before adding the `code.*` KeyValue attributes in `on_new_span`. In addition, `with_event_location` was renamed to `with_location`, as it now controls both span *and* event locations, and the `with_event_location` method has been deprecated. ## Testing Additional unit tests are included in [tracing-opentelemetry/src/subscriber.rs] to cover both boolean cases of `with_location`. [`with_event_location`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L343 [`on_new_span`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L448-L460 [`on_event`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L582 [tracing-opentelemetry/src/subscriber.rs]: https://github.com/tokio-rs/tracing/pull/2124/files#diff-69011e8b23dffcbe19b9b72e5ac54330a7871f424a90700ed7f5c5686daf431bR911-R975)
# 0.17.3 (June 7, 2022) This release adds support for emitting thread names and IDs to OpenTelemetry, as well as recording `std::error::Error` values in a structured manner with their source chain included. Additionally, this release fixes issues related to event and span source code locations. ### Added - `Layer::with_threads` to enable recording thread names/IDs according to [OpenTelemetry semantic conventions][thread-semconv] ([#2134]) - `Error::source` chain when recording `std::error::Error` values ([#2122]) - `Layer::with_location` method (replaces `Layer::with_event_location`) ([#2124]) ### Changed - `std::error::Error` values are now recorded using `fmt::Display` rather than `fmt::Debug` ([#2122]) ### Fixed - Fixed event source code locations overwriting the parent span's source location ([#2099]) - Fixed `Layer::with_event_location` not controlling whether locations are emitted for spans as well as events ([#2124]) ### Deprecated - `Layer::with_event_location`: renamed to `Layer::with_location`, as it now controls both span and event locations ([#2124]) [thread-semconv]: https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/span-general/#source-code-attributes [#2134]: #2134 [#2122]: #2122 [#2124]: #2124 [#2099]: #2099
# 0.17.3 (June 7, 2022) This release adds support for emitting thread names and IDs to OpenTelemetry, as well as recording `std::error::Error` values in a structured manner with their source chain included. Additionally, this release fixes issues related to event and span source code locations. ### Added - `Layer::with_threads` to enable recording thread names/IDs according to [OpenTelemetry semantic conventions][thread-semconv] ([#2134]) - `Error::source` chain when recording `std::error::Error` values ([#2122]) - `Layer::with_location` method (replaces `Layer::with_event_location`) ([#2124]) ### Changed - `std::error::Error` values are now recorded using `fmt::Display` rather than `fmt::Debug` ([#2122]) ### Fixed - Fixed event source code locations overwriting the parent span's source location ([#2099]) - Fixed `Layer::with_event_location` not controlling whether locations are emitted for spans as well as events ([#2124]) ### Deprecated - `Layer::with_event_location`: renamed to `Layer::with_location`, as it now controls both span and event locations ([#2124]) Thanks to new contributors @lilymara-onesignal, @hubertbudzynski, and @DevinCarr for contributing to this release! [thread-semconv]: https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/span-general/#source-code-attributes [#2134]: #2134 [#2122]: #2122 [#2124]: #2124 [#2099]: #2099
# 0.17.3 (June 7, 2022) This release adds support for emitting thread names and IDs to OpenTelemetry, as well as recording `std::error::Error` values in a structured manner with their source chain included. Additionally, this release fixes issues related to event and span source code locations. ### Added - `Layer::with_threads` to enable recording thread names/IDs according to [OpenTelemetry semantic conventions][thread-semconv] ([#2134]) - `Error::source` chain when recording `std::error::Error` values ([#2122]) - `Layer::with_location` method (replaces `Layer::with_event_location`) ([#2124]) ### Changed - `std::error::Error` values are now recorded using `fmt::Display` rather than `fmt::Debug` ([#2122]) ### Fixed - Fixed event source code locations overwriting the parent span's source location ([#2099]) - Fixed `Layer::with_event_location` not controlling whether locations are emitted for spans as well as events ([#2124]) ### Deprecated - `Layer::with_event_location`: renamed to `Layer::with_location`, as it now controls both span and event locations ([#2124]) Thanks to new contributors @lilymara-onesignal, @hubertbudzynski, and @DevinCarr for contributing to this release! [thread-semconv]: https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/span-general/#source-code-attributes [#2134]: tokio-rs/tracing#2134 [#2122]: tokio-rs/tracing#2122 [#2124]: tokio-rs/tracing#2124 [#2099]: tokio-rs/tracing#2099
The `with_event_location(false)` method will now properly omit `code.*` tags from spans. ## Motivation Recently, I attempted to remove the `code.*` tags from opentelemetry tracing spans utilizing the [`with_event_location`] of OpenTelemetrySubscriber. This did not work as expected because the [`on_new_span`] doesn't account for the `event_location` boolean similar to how [`on_event`] does. ## Solution The change presented will expand the use of the `location` field to check before adding the `code.*` KeyValue attributes in `on_new_span`. In addition, `with_event_location` was renamed to `with_location`, as it now controls both span *and* event locations, and the `with_event_location` method has been deprecated. ## Testing Additional unit tests are included in [tracing-opentelemetry/src/subscriber.rs] to cover both boolean cases of `with_location`. [`with_event_location`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L343 [`on_new_span`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L448-L460 [`on_event`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L582 [tracing-opentelemetry/src/subscriber.rs]: https://github.com/tokio-rs/tracing/pull/2124/files#diff-69011e8b23dffcbe19b9b72e5ac54330a7871f424a90700ed7f5c5686daf431bR911-R975)
# 0.17.3 (June 7, 2022) This release adds support for emitting thread names and IDs to OpenTelemetry, as well as recording `std::error::Error` values in a structured manner with their source chain included. Additionally, this release fixes issues related to event and span source code locations. ### Added - `Layer::with_threads` to enable recording thread names/IDs according to [OpenTelemetry semantic conventions][thread-semconv] ([tokio-rs#2134]) - `Error::source` chain when recording `std::error::Error` values ([tokio-rs#2122]) - `Layer::with_location` method (replaces `Layer::with_event_location`) ([tokio-rs#2124]) ### Changed - `std::error::Error` values are now recorded using `fmt::Display` rather than `fmt::Debug` ([tokio-rs#2122]) ### Fixed - Fixed event source code locations overwriting the parent span's source location ([tokio-rs#2099]) - Fixed `Layer::with_event_location` not controlling whether locations are emitted for spans as well as events ([tokio-rs#2124]) ### Deprecated - `Layer::with_event_location`: renamed to `Layer::with_location`, as it now controls both span and event locations ([tokio-rs#2124]) Thanks to new contributors @lilymara-onesignal, @hubertbudzynski, and @DevinCarr for contributing to this release! [thread-semconv]: https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/span-general/#source-code-attributes [tokio-rs#2134]: tokio-rs#2134 [tokio-rs#2122]: tokio-rs#2122 [tokio-rs#2124]: tokio-rs#2124 [tokio-rs#2099]: tokio-rs#2099
The
with_event_location(false)
method will now properly omitcode.*
tags from spans.Motivation
Recently, I attempted to remove the
code.*
tags from opentelemetry tracing spans utilizing thewith_event_location
of OpenTelemetrySubscriber. This did not work as expected because theon_new_span
doesn't account for theevent_location
boolean similar to howon_event
does.Solution
The change presented will expand the use of the
event_location
to check before adding thecode.*
KeyValue attributes inon_new_span
.Testing
Additional unit tests are included in tracing-opentelemetry/src/subscriber.rs to cover both boolean cases of
with_event_location
.